/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package de.swta;

import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;

/**
 *
 * @author Jan Korreck
 */
public class MyPropertyColumn extends PropertyColumn {

    public MyPropertyColumn(IModel displayModel, String propertyExpression) {
        super(displayModel, propertyExpression);
    }

    public MyPropertyColumn(IModel displayModel, String sortProperty, String propertyExpression) {
        super(displayModel, sortProperty, propertyExpression);
    }

    @Override
    public void populateItem(Item item, String componentId, IModel rowModel) {

        System.out.println("________MODEL: " + rowModel.toString());
        MyItemPackage p = (MyItemPackage) rowModel.getObject();

        System.out.println("ID" + p.getId() + " Title" + p.getTitle());

//        item.add(new Label(componentId, super.createLabelModel(rowModel)));
//        item.add(new Loop(componentId, p.getItemList().size()) {
//
//            @Override
//            protected void populateItem(LoopItem item) {
//                System.out.println("_________-LoopItem: " + item.toString());
//            }
//        });

        item.add(new ListView("listview3", p.getItemList()) {

            protected void populateItem(ListItem item) {
                MyItem actItem = (MyItem) item.getModelObject();

                item.add(new Label("itemName", actItem.getName()));
            }
        });

        System.out.println("________Item: " + item.toString());
//        super.populateItem(item, componentId, rowModel);
    }


}
